/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SignIn.java
 *
 * Created on Jun 5, 2010, 3:53:19 PM
 */

package frontEnd;

import javax.swing.JOptionPane;

/**
 *
 * @author hiralrajani
 */
public class SignIn extends javax.swing.JFrame {

    /** Creates new form SignIn */
    public SignIn() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        player1Text = new javax.swing.JTextField();
        player2Text = new javax.swing.JTextField();
        player1Label = new javax.swing.JLabel();
        player2Label = new javax.swing.JLabel();
        startButton = new javax.swing.JButton();
        selectGameLabel = new javax.swing.JLabel();
        selectGameCombo = new javax.swing.JComboBox();
        image1Label = new javax.swing.JLabel();
        image2Label = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Superply");
        setBackground(new java.awt.Color(218, 112, 214));
        setForeground(java.awt.Color.orange);
        setMinimumSize(new java.awt.Dimension(600, 600));
        setName("Login"); // NOI18N
        setResizable(false);

        mainPanel.setBackground(new java.awt.Color(204, 153, 255));
        mainPanel.setFocusable(false);

        player1Text.setFont(new java.awt.Font("Arial", 1, 12));
        player1Text.setMinimumSize(new java.awt.Dimension(75, 25));
        player1Text.setPreferredSize(new java.awt.Dimension(75, 25));

        player2Text.setFont(new java.awt.Font("Arial", 1, 12));
        player2Text.setMinimumSize(new java.awt.Dimension(75, 25));
        player2Text.setPreferredSize(new java.awt.Dimension(75, 25));

        player1Label.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        player1Label.setText("PLAYER 1");

        player2Label.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        player2Label.setText("PLAYER 2");

        startButton.setFont(new java.awt.Font("Arial", 1, 12));
        startButton.setText("Start");
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });

        selectGameLabel.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        selectGameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        selectGameLabel.setText("SELECT GAME");

        selectGameCombo.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        selectGameCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Addition", "Multiplication" }));
        selectGameCombo.setToolTipText("select game");

        image1Label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/frontEnd/owl.jpg"))); // NOI18N

        image2Label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/frontEnd/super2.jpg"))); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGap(159, 159, 159)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(player1Text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(player1Label)))
                        .addGap(201, 201, 201)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(player2Label))
                            .addComponent(player2Text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGap(129, 129, 129)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(selectGameCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(selectGameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(152, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addContainerGap(186, Short.MAX_VALUE)
                .addComponent(image2Label)
                .addGap(176, 176, 176))
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGap(284, 284, 284)
                .addComponent(image1Label)
                .addContainerGap(288, Short.MAX_VALUE))
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGap(292, 292, 292)
                .addComponent(startButton)
                .addContainerGap(309, Short.MAX_VALUE))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addContainerGap(63, Short.MAX_VALUE)
                .addComponent(image1Label)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(image2Label)
                .addGap(65, 65, 65)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(player1Text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(player1Label)
                        .addGap(23, 23, 23)
                        .addComponent(selectGameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(player2Text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(player2Label)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(selectGameCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23)
                .addComponent(startButton)
                .addGap(40, 40, 40))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
        if(validateText())
        {
            this.setVisible(false);
            new GameScreen(selectGameCombo.getSelectedItem().toString(), player1Text.getText(), player2Text.getText()).setVisible(true);
        }
        //JOptionPane.showMessageDialog(rootPane, "Hey");
    }//GEN-LAST:event_startButtonActionPerformed

    private boolean validateText(){
       if(player1Text.getText() != "" && player2Text.getText() != ""){
           return true;
       }
       JOptionPane.showMessageDialog(rootPane, "Oops! Player names are required");
        return false;
    }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SignIn().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel image1Label;
    private javax.swing.JLabel image2Label;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JLabel player1Label;
    private javax.swing.JTextField player1Text;
    private javax.swing.JLabel player2Label;
    private javax.swing.JTextField player2Text;
    private javax.swing.JComboBox selectGameCombo;
    private javax.swing.JLabel selectGameLabel;
    private javax.swing.JButton startButton;
    // End of variables declaration//GEN-END:variables

}
